
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>建造者模式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sidebar-style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="原型模式.html" />
    
    
    <link rel="prev" href="单例模式.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">基础篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../java基础/IO流基础.html">
            
                <a href="../java基础/IO流基础.html">
            
                    
                    IO流基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../java基础/集合.html">
            
                <a href="../java基础/集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../java基础/异常处理.html">
            
                <a href="../java基础/异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../java基础/线程.html">
            
                <a href="../java基础/线程.html">
            
                    
                    线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../java基础/网络编程.html">
            
                <a href="../java基础/网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="MySQL.html">
            
                <a href="MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="Oracle.html">
            
                <a href="Oracle.html">
            
                    
                    Oracle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="Redis.html">
            
                <a href="Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="Netty.html">
            
                <a href="Netty.html">
            
                    
                    Netty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="Spring.html">
            
                <a href="Spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="SpringMVC.html">
            
                <a href="SpringMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="单元测试.html">
            
                <a href="单元测试.html">
            
                    
                    SpringBoot单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="设计模式.html">
            
                <a href="设计模式.html">
            
                    
                    二十三个设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="工厂模式.html">
            
                <a href="工厂模式.html">
            
                    
                    工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="单例模式.html">
            
                <a href="单例模式.html">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.8.3" data-path="建造者模式.html">
            
                <a href="建造者模式.html">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="原型模式.html">
            
                <a href="原型模式.html">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.5" data-path="适配器模式.html">
            
                <a href="适配器模式.html">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="责任链模式.html">
            
                <a href="责任链模式.html">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.7" data-path="桥接模式.html">
            
                <a href="桥接模式.html">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">高级篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../springcloud/1.cloud架构选型.html">
            
                <a href="../springcloud/1.cloud架构选型.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../springcloud/2.Provider-支付模块.html">
            
                <a href="../springcloud/2.Provider-支付模块.html">
            
                    
                    Provider-支付模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../springcloud/3.Consumer-订单模块.html">
            
                <a href="../springcloud/3.Consumer-订单模块.html">
            
                    
                    Consumer-订单模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../springcloud/4.重构-Common模块.html">
            
                <a href="../springcloud/4.重构-Common模块.html">
            
                    
                    重构-Common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../springcloud/5.注册中心-Enreka.html">
            
                <a href="../springcloud/5.注册中心-Enreka.html">
            
                    
                    注册中心-Enreka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../springcloud/6.负载均衡-@LoadBalance.html">
            
                <a href="../springcloud/6.负载均衡-@LoadBalance.html">
            
                    
                    负载均衡-@LoadBalance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../springcloud/7.更换注册中心-Zookeeper.html">
            
                <a href="../springcloud/7.更换注册中心-Zookeeper.html">
            
                    
                    更换注册中心-Zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../springcloud/8.更换注册中心-Consul.html">
            
                <a href="../springcloud/8.更换注册中心-Consul.html">
            
                    
                    更换注册中心-Consul
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../springcloud/9.负载均衡-Ribbon.html">
            
                <a href="../springcloud/9.负载均衡-Ribbon.html">
            
                    
                    负载均衡-Ribbon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="../springcloud/10.服务调用-OpenFeign.html">
            
                <a href="../springcloud/10.服务调用-OpenFeign.html">
            
                    
                    服务调用-OpenFeign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.10" data-path="../springcloud/11.熔断器-Hystrix.html">
            
                <a href="../springcloud/11.熔断器-Hystrix.html">
            
                    
                    熔断器-Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.11" data-path="../springcloud/12.网关-Gateway.html">
            
                <a href="../springcloud/12.网关-Gateway.html">
            
                    
                    网关-Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.12" data-path="../springcloud/13.配置中心-Config.html">
            
                <a href="../springcloud/13.配置中心-Config.html">
            
                    
                    配置中心-Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.13" data-path="../springcloud/14.消息总线-bus.html">
            
                <a href="../springcloud/14.消息总线-bus.html">
            
                    
                    消息总线-Bus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.14" data-path="../springcloud/15.消息驱动-stream.html">
            
                <a href="../springcloud/15.消息驱动-stream.html">
            
                    
                    消息驱动-Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.15" data-path="../springcloud/16.链路监控-Sleuth.html">
            
                <a href="../springcloud/16.链路监控-Sleuth.html">
            
                    
                    链路监控-Sleuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.16" data-path="../springcloud/17.注册中心&配置中心-nacos.html">
            
                <a href="../springcloud/17.注册中心&配置中心-nacos.html">
            
                    
                    注册中心&配置中心-nacos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.17" data-path="../springcloud/18.限流-sentinel.html">
            
                <a href="../springcloud/18.限流-sentinel.html">
            
                    
                    限流-sentinel
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../java高级/JUC.html">
            
                <a href="../java高级/JUC.html">
            
                    
                    神秘的JUC包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../java高级/Docker.html">
            
                <a href="../java高级/Docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../java高级/布隆过滤器.html">
            
                <a href="../java高级/布隆过滤器.html">
            
                    
                    布隆过滤器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../java高级/Redission.html">
            
                <a href="../java高级/Redission.html">
            
                    
                    Redission
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../java高级/MQ.html">
            
                <a href="../java高级/MQ.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../java高级/JVM.html">
            
                <a href="../java高级/JVM.html">
            
                    
                    JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../java书籍/《Effective Java》读书笔记.html">
            
                <a href="../java书籍/《Effective Java》读书笔记.html">
            
                    
                    《Effective Java》读书笔记 
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="../java书籍/创建和销毁对象.html">
            
                <a href="../java书籍/创建和销毁对象.html">
            
                    
                    创建和销毁对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">番外篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../java面试/面试题.html">
            
                <a href="../java面试/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../番外篇/小程序.html">
            
                <a href="../番外篇/小程序.html">
            
                    
                    微信小程序
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >建造者模式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <blockquote>
<p>&#x53C2;&#x8003;&#x94FE;&#x63A5;&#xFF1A;<a href="https://www.runoob.com/design-pattern/builder-pattern.html" target="_blank">https://www.runoob.com/design-pattern/builder-pattern.html</a> &#xFF08;&#x83DC;&#x9E1F;&#x6559;&#x7A0B;&#xFF09;</p>
</blockquote>
<p>&#x5EFA;&#x9020;&#x8005;&#x6A21;&#x5F0F;&#x53C8;&#x88AB;&#x79F0;&#x547C;&#x4E3A;<strong>&#x751F;&#x6210;&#x5668;&#x6A21;&#x5F0F;</strong>&#xFF0C;&#x539F;&#x7406;&#x662F;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5BF9;&#x8C61;&#x4E00;&#x6B65;&#x4E00;&#x6B65;&#x6784;&#x5EFA;&#x6210;&#x4E00;&#x4E2A;&#x590D;&#x6742;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6709;&#x70B9;&#x50CF;&#x9020;&#x623F;&#x5B50;&#x4E00;&#x6837;&#x4E00;&#x6B65;&#x6B65;&#x4ECE;&#x5730;&#x57FA;&#x505A;&#x8D77;&#x5230;&#x4E07;&#x4E08;&#x9AD8;&#x697C;&#x3002;&#x4F7F;&#x7528;&#x573A;&#x666F;&#x53EA;&#x8981;&#x662F;<strong>&#x6784;&#x9020;&#x51FD;&#x6570;&#x9700;&#x8981;4&#x4E2A;&#x4EE5;&#x4E0A;&#x7684;&#x53C2;&#x6570;,&#x4E14;&#x6709;&#x4E9B;&#x662F;&#x5FC5;&#x4F20;&#xFF0C;&#x6709;&#x4E9B;&#x662F;&#x53EF;&#x9009;</strong>&#x3002;</p>
<p><strong>&#x4E3B;&#x8981;&#x89E3;&#x51B3;&#xFF1A;</strong>&#x4E3B;&#x8981;&#x89E3;&#x51B3;&#x5728;&#x8F6F;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#x9762;&#x4E34;&#x7740;&quot;&#x4E00;&#x4E2A;&#x590D;&#x6742;&#x5BF9;&#x8C61;&quot;&#x7684;&#x521B;&#x5EFA;&#x5DE5;&#x4F5C;&#xFF0C;&#x5176;&#x901A;&#x5E38;&#x7531;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x7684;&#x5B50;&#x5BF9;&#x8C61;&#x7528;&#x4E00;&#x5B9A;&#x7684;&#x7B97;&#x6CD5;&#x6784;&#x6210;&#xFF1B;&#x7531;&#x4E8E;&#x9700;&#x6C42;&#x7684;&#x53D8;&#x5316;&#xFF0C;&#x8FD9;&#x4E2A;&#x590D;&#x6742;&#x5BF9;&#x8C61;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x7ECF;&#x5E38;&#x9762;&#x4E34;&#x7740;&#x5267;&#x70C8;&#x7684;&#x53D8;&#x5316;&#xFF0C;&#x4F46;&#x662F;&#x5C06;&#x5B83;&#x4EEC;&#x7EC4;&#x5408;&#x5728;&#x4E00;&#x8D77;&#x7684;&#x7B97;&#x6CD5;&#x5374;&#x76F8;&#x5BF9;&#x7A33;&#x5B9A;&#x3002;</p>
<p><strong>&#x4F55;&#x65F6;&#x4F7F;&#x7528;&#xFF1A;</strong>&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x90E8;&#x4EF6;&#x4E0D;&#x4F1A;&#x53D8;&#xFF0C;&#x800C;&#x5176;&#x7EC4;&#x5408;&#x7ECF;&#x5E38;&#x53D8;&#x5316;&#x7684;&#x65F6;&#x5019;&#x3002;</p>
<p><strong>&#x5982;&#x4F55;&#x89E3;&#x51B3;&#xFF1A;</strong>&#x5C06;&#x53D8;&#x4E0E;&#x4E0D;&#x53D8;&#x5206;&#x79BB;&#x5F00;&#x3002;</p>
<p><strong>&#x5173;&#x952E;&#x4EE3;&#x7801;&#xFF1A;</strong>&#x5EFA;&#x9020;&#x8005;&#xFF1A;&#x521B;&#x5EFA;&#x548C;&#x63D0;&#x4F9B;&#x5B9E;&#x4F8B;&#xFF0C;&#x5BFC;&#x6F14;&#xFF1A;&#x7BA1;&#x7406;&#x5EFA;&#x9020;&#x51FA;&#x6765;&#x7684;&#x5B9E;&#x4F8B;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<p><strong>&#x5E94;&#x7528;&#x5B9E;&#x4F8B;&#xFF1A;</strong> 1&#x3001;&#x53BB;&#x80AF;&#x5FB7;&#x57FA;&#xFF0C;&#x6C49;&#x5821;&#x3001;&#x53EF;&#x4E50;&#x3001;&#x85AF;&#x6761;&#x3001;&#x70B8;&#x9E21;&#x7FC5;&#x7B49;&#x662F;&#x4E0D;&#x53D8;&#x7684;&#xFF0C;&#x800C;&#x5176;&#x7EC4;&#x5408;&#x662F;&#x7ECF;&#x5E38;&#x53D8;&#x5316;&#x7684;&#xFF0C;&#x751F;&#x6210;&#x51FA;&#x6240;&#x8C13;&#x7684;&quot;&#x5957;&#x9910;&quot;&#x3002; 2&#x3001;JAVA &#x4E2D;&#x7684; StringBuilder&#x3002;</p>
<p><strong>&#x4F7F;&#x7528;&#x573A;&#x666F;&#xFF1A;</strong> 1&#x3001;&#x9700;&#x8981;&#x751F;&#x6210;&#x7684;&#x5BF9;&#x8C61;&#x5177;&#x6709;&#x590D;&#x6742;&#x7684;&#x5185;&#x90E8;&#x7ED3;&#x6784;&#x3002; 2&#x3001;&#x9700;&#x8981;&#x751F;&#x6210;&#x7684;&#x5BF9;&#x8C61;&#x5185;&#x90E8;&#x5C5E;&#x6027;&#x672C;&#x8EAB;&#x76F8;&#x4E92;&#x4F9D;&#x8D56;&#x3002;</p>
<p><img src="https://tva1.sinaimg.cn/large/e6c9d24ely1h3mns8df00j21440u042u.jpg" alt="UML&#x56FE;"></p>
<p><strong>&#x5B9A;&#x4E49;&#x5546;&#x54C1;&#x548C;&#x5305;&#x88C5;(&#x63A5;&#x53E3;)</strong></p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x5546;&#x54C1;&#x63A5;&#x53E3;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Item</span> </span>{
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">name</span><span class="hljs-params">()</span></span>;
   <span class="hljs-function"><span class="hljs-keyword">public</span> Packing <span class="hljs-title">packing</span><span class="hljs-params">()</span></span>;
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span></span>;    
}
<span class="hljs-comment">//&#x5305;&#x88C5;&#x63A5;&#x53E3;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Packing</span> </span>{
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">pack</span><span class="hljs-params">()</span></span>;
}
</code></pre>
<p><strong>&#x521B;&#x5EFA;&#x5B9E;&#x73B0; Packing &#x63A5;&#x53E3;&#x7684;&#x5B9E;&#x4F53;&#x7C7B;</strong></p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x76D2;&#x88C5;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Wrapper</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Packing</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">pack</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Wrapper&quot;</span>;
   }
}

<span class="hljs-comment">//&#x74F6;&#x88C5;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Bottle</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Packing</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">pack</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Bottle&quot;</span>;
   }
}
</code></pre>
<p>&#x521B;&#x5EFA;&#x5B9E;&#x73B0;Item&#x63A5;&#x53E3;&#x7684;&#x62BD;&#x8C61;&#x5B9E;&#x4F53;&#x7C7B;</p>
<pre><code class="lang-java"><span class="hljs-comment">// &#x6C49;&#x5821;</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Burger</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Item</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> Packing <span class="hljs-title">packing</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Wrapper();
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span></span>;
}

<span class="hljs-comment">//&#x53EF;&#x4E50;</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ColdDrink</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Item</span> </span>{

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Packing <span class="hljs-title">packing</span><span class="hljs-params">()</span> </span>{
       <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Bottle();
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span></span>;
}
</code></pre>
<p>&#x521B;&#x5EFA;&#x62BD;&#x8C61;&#x5546;&#x54C1;&#x7684;&#x5B9E;&#x73B0;&#x7C7B;</p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x852C;&#x83DC;&#x6C49;&#x5821;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">VegBurger</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Burger</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-number">25.0f</span>;
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">name</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Veg Burger&quot;</span>;
   }
}
<span class="hljs-comment">//&#x9E21;&#x8089;&#x6C49;&#x5821;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ChickenBurger</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Burger</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-number">50.5f</span>;
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">name</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Chicken Burger&quot;</span>;
   }
}

<span class="hljs-comment">//&#x53EF;&#x53E3;&#x53EF;&#x4E50;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Coke</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">ColdDrink</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-number">30.0f</span>;
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">name</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Coke&quot;</span>;
   }
}

<span class="hljs-comment">//&#x767E;&#x4E8B;&#x53EF;&#x4E50;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Pepsi</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">ColdDrink</span> </span>{

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">price</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-number">35.0f</span>;
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">name</span><span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Pepsi&quot;</span>;
   }
}
</code></pre>
<p>&#x521B;&#x5EFA;&#x5957;&#x9910;&#x7C7B;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Meal</span> </span>{
   <span class="hljs-keyword">private</span> List&lt;Item&gt; items = <span class="hljs-keyword">new</span> ArrayList&lt;Item&gt;();    

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">addItem</span><span class="hljs-params">(Item item)</span></span>{
      items.add(item);
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">float</span> <span class="hljs-title">getCost</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">float</span> cost = <span class="hljs-number">0.0f</span>;
      <span class="hljs-keyword">for</span> (Item item : items) {
         cost += item.price();
      }        
      <span class="hljs-keyword">return</span> cost;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">showItems</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">for</span> (Item item : items) {
         System.out.print(<span class="hljs-string">&quot;Item : &quot;</span>+item.name());
         System.out.print(<span class="hljs-string">&quot;, Packing : &quot;</span>+item.packing().pack());
         System.out.println(<span class="hljs-string">&quot;, Price : &quot;</span>+item.price());
      }        
   }    
}
</code></pre>
<p>&#x521B;&#x5EFA;&#x5957;&#x9910;Builder</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MealBuilder</span> </span>{

   <span class="hljs-function"><span class="hljs-keyword">public</span> Meal <span class="hljs-title">prepareVegMeal</span> <span class="hljs-params">()</span></span>{
      Meal meal = <span class="hljs-keyword">new</span> Meal();
      meal.addItem(<span class="hljs-keyword">new</span> VegBurger());
      meal.addItem(<span class="hljs-keyword">new</span> Coke());
      <span class="hljs-keyword">return</span> meal;
   }   

   <span class="hljs-function"><span class="hljs-keyword">public</span> Meal <span class="hljs-title">prepareNonVegMeal</span> <span class="hljs-params">()</span></span>{
      Meal meal = <span class="hljs-keyword">new</span> Meal();
      meal.addItem(<span class="hljs-keyword">new</span> ChickenBurger());
      meal.addItem(<span class="hljs-keyword">new</span> Pepsi());
      <span class="hljs-keyword">return</span> meal;
   }
}
</code></pre>
<p>&#x300A;Effective Java &#x300B;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x65B9;&#x5F0F;&#xFF1A;</p>
<hr>
<ul>
<li>&#x6298;&#x53E0;&#x6784;&#x9020;&#x5668;</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Computer</span> </span>{
    <span class="hljs-keyword">private</span> String cpu;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> String ram;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> usbCount;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String keyboard;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String display;<span class="hljs-comment">//&#x53EF;&#x9009;</span>

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Computer</span><span class="hljs-params">(String cpu, String ram)</span> </span>{
        <span class="hljs-keyword">this</span>(cpu, ram, <span class="hljs-number">0</span>);
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Computer</span><span class="hljs-params">(String cpu, String ram, <span class="hljs-keyword">int</span> usbCount)</span> </span>{
        <span class="hljs-keyword">this</span>(cpu, ram, usbCount, <span class="hljs-string">&quot;&#x7F57;&#x6280;&#x952E;&#x76D8;&quot;</span>);
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Computer</span><span class="hljs-params">(String cpu, String ram, <span class="hljs-keyword">int</span> usbCount, String keyboard)</span> </span>{
        <span class="hljs-keyword">this</span>(cpu, ram, usbCount, keyboard, <span class="hljs-string">&quot;&#x4E09;&#x661F;&#x663E;&#x793A;&#x5668;&quot;</span>);
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Computer</span><span class="hljs-params">(String cpu, String ram, <span class="hljs-keyword">int</span> usbCount, String keyboard, String display)</span> </span>{
        <span class="hljs-keyword">this</span>.cpu = cpu;
        <span class="hljs-keyword">this</span>.ram = ram;
        <span class="hljs-keyword">this</span>.usbCount = usbCount;
        <span class="hljs-keyword">this</span>.keyboard = keyboard;
        <span class="hljs-keyword">this</span>.display = display;
    }
}
</code></pre>
<ul>
<li>JavaBean</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Computer</span> </span>{
    <span class="hljs-keyword">private</span> String cpu;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> String ram;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> usbCount;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String keyboard;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String display;<span class="hljs-comment">//&#x53EF;&#x9009;</span>

    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getCpu</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> cpu;
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setCpu</span><span class="hljs-params">(String cpu)</span> </span>{
        <span class="hljs-keyword">this</span>.cpu = cpu;
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getRam</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> ram;
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setRam</span><span class="hljs-params">(String ram)</span> </span>{
        <span class="hljs-keyword">this</span>.ram = ram;
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">getUsbCount</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> usbCount;
    }
        <span class="hljs-comment">//...</span>
}
</code></pre>
<p>&#x4E0A;&#x8FF0;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x5B58;&#x5728;&#x7684;&#x95EE;&#x9898;&#xFF1A;</p>
<ul>
<li>&#x7B2C;&#x4E00;&#x79CD;&#x4E3B;&#x8981;&#x662F;&#x4F7F;&#x7528;&#x53CA;&#x9605;&#x8BFB;&#x4E0D;&#x65B9;&#x4FBF;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x60F3;&#x8C61;&#x4E00;&#x4E0B;&#xFF0C;&#x5F53;&#x4F60;&#x8981;&#x8C03;&#x7528;&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x4F60;&#x9996;&#x5148;&#x8981;&#x51B3;&#x5B9A;&#x4F7F;&#x7528;&#x54EA;&#x4E00;&#x4E2A;&#xFF0C;&#x7136;&#x540E;&#x91CC;&#x9762;&#x53C8;&#x662F;&#x4E00;&#x5806;&#x53C2;&#x6570;&#xFF0C;&#x5982;&#x679C;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x5F88;&#x591A;&#x53C8;&#x90FD;&#x4E00;&#x6837;&#xFF0C;&#x4F60;&#x8FD8;&#x8981;&#x641E;&#x6E05;&#x695A;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x7684;&#x542B;&#x4E49;&#xFF0C;&#x5F88;&#x5BB9;&#x6613;&#x5C31;&#x4F20;&#x6DF7;&#x4E86;&#x3002;&#x3002;&#x3002;</li>
<li>&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x5F0F;&#x5728;&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x4E2D;&#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x5BB9;&#x6613;&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;&#x9020;&#x6210;&#x9519;&#x8BEF;&#x3002;&#x56E0;&#x4E3A;&#x90A3;&#x4E2A;&#x7C7B;&#x4E2D;&#x7684;&#x5C5E;&#x6027;&#x662F;&#x5206;&#x6B65;&#x8BBE;&#x7F6E;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x5C31;&#x5BB9;&#x6613;&#x51FA;&#x9519;&#x3002;</li>
</ul>
<p>&#x6240;&#x4EE5;&#x63A5;&#x4E0B;&#x6765;&#x7528;&#x5EFA;&#x9020;&#x8005;&#x6A21;&#x5F0F;&#x6765;&#x4FEE;&#x6539;&#xFF1A;</p>
<ol>
<li>&#x5728;Computer &#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9759;&#x6001;&#x5185;&#x90E8;&#x7C7B; Builder&#xFF0C;&#x7136;&#x540E;&#x5C06;Computer &#x4E2D;&#x7684;&#x53C2;&#x6570;&#x90FD;&#x590D;&#x5236;&#x5230;Builder&#x7C7B;&#x4E2D;&#x3002;</li>
<li>&#x5728;Computer&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;private&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x53C2;&#x6570;&#x4E3A;Builder&#x7C7B;&#x578B;</li>
<li>&#x5728;Builder&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>public</code>&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x53C2;&#x6570;&#x4E3A;Computer&#x4E2D;&#x5FC5;&#x586B;&#x7684;&#x90A3;&#x4E9B;&#x53C2;&#x6570;&#xFF0C;cpu &#x548C;ram&#x3002;</li>
<li>&#x5728;Builder&#x4E2D;&#x521B;&#x5EFA;&#x8BBE;&#x7F6E;&#x51FD;&#x6570;&#xFF0C;&#x5BF9;Computer&#x4E2D;&#x90A3;&#x4E9B;&#x53EF;&#x9009;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#xFF0C;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;Builder&#x7C7B;&#x578B;&#x7684;&#x5B9E;&#x4F8B;</li>
<li>&#x5728;Builder&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>build()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5728;&#x5176;&#x4E2D;&#x6784;&#x5EFA;Computer&#x7684;&#x5B9E;&#x4F8B;&#x5E76;&#x8FD4;&#x56DE;</li>
</ol>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Computer</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String cpu;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String ram;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> usbCount;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String keyboard;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
    <span class="hljs-keyword">private</span> String display;<span class="hljs-comment">//&#x53EF;&#x9009;</span>

        <span class="hljs-comment">//&#x7701;&#x7565;getter&#x65B9;&#x6CD5;</span>

      <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">Computer</span><span class="hljs-params">(Builder builder)</span></span>{
        <span class="hljs-keyword">this</span>.cpu=builder.cpu;
        <span class="hljs-keyword">this</span>.ram=builder.ram;
        <span class="hljs-keyword">this</span>.usbCount=builder.usbCount;
        <span class="hljs-keyword">this</span>.keyboard=builder.keyboard;
        <span class="hljs-keyword">this</span>.display=builder.display;
    }

    <span class="hljs-comment">//&#x9759;&#x6001;&#x5185;&#x90E8;&#x7C7B;</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Builder</span></span>{
        <span class="hljs-keyword">private</span> String cpu;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
        <span class="hljs-keyword">private</span> String ram;<span class="hljs-comment">//&#x5FC5;&#x987B;</span>
        <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> usbCount;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
        <span class="hljs-keyword">private</span> String keyboard;<span class="hljs-comment">//&#x53EF;&#x9009;</span>
        <span class="hljs-keyword">private</span> String display;<span class="hljs-comment">//&#x53EF;&#x9009;</span>

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Builder</span><span class="hljs-params">(String cup,String ram)</span></span>{
            <span class="hljs-keyword">this</span>.cpu=cup;
            <span class="hljs-keyword">this</span>.ram=ram;
        }

        <span class="hljs-function"><span class="hljs-keyword">public</span> Builder <span class="hljs-title">setUsbCount</span><span class="hljs-params">(<span class="hljs-keyword">int</span> usbCount)</span> </span>{
            <span class="hljs-keyword">this</span>.usbCount = usbCount;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
        }
        <span class="hljs-function"><span class="hljs-keyword">public</span> Builder <span class="hljs-title">setKeyboard</span><span class="hljs-params">(String keyboard)</span> </span>{
            <span class="hljs-keyword">this</span>.keyboard = keyboard;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
        }
        <span class="hljs-function"><span class="hljs-keyword">public</span> Builder <span class="hljs-title">setDisplay</span><span class="hljs-params">(String display)</span> </span>{
            <span class="hljs-keyword">this</span>.display = display;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
        }        
        <span class="hljs-function"><span class="hljs-keyword">public</span> Computer <span class="hljs-title">build</span><span class="hljs-params">()</span></span>{
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Computer(<span class="hljs-keyword">this</span>);
        }
    }
}
</code></pre>
<p>&#x6700;&#x540E;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre><code class="lang-java">Computer computer=<span class="hljs-keyword">new</span> Computer.Builder(<span class="hljs-string">&quot;&#x56E0;&#x7279;&#x5C14;&quot;</span>,<span class="hljs-string">&quot;&#x4E09;&#x661F;&quot;</span>)
                .setDisplay(<span class="hljs-string">&quot;&#x4E09;&#x661F;24&#x5BF8;&quot;</span>)
                .setKeyboard(<span class="hljs-string">&quot;&#x7F57;&#x6280;&quot;</span>)
                .setUsbCount(<span class="hljs-number">2</span>)
                .build();
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; mine 2022-2025 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2022-06-28 12:14:11
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="单例模式.html" class="navigation navigation-prev " aria-label="Previous page: 单例模式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="原型模式.html" class="navigation navigation-next " aria-label="Next page: 原型模式">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"建造者模式","level":"3.8.3","depth":2,"next":{"title":"原型模式","level":"3.8.4","depth":2,"path":"java进阶/原型模式.md","ref":"java进阶/原型模式.md","articles":[]},"previous":{"title":"单例模式","level":"3.8.2","depth":2,"path":"java进阶/单例模式.md","ref":"java进阶/单例模式.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["back-to-top-button","code","splitter","expandable-chapters-small","anchors","theme-comscore","tbfed-pagefooter","sidebar-style","pageview-count","popup"],"pluginsConfig":{"sidebar-style":{"author":"梁兴龙","title":"《Java 笔记本》"},"tbfed-pagefooter":{"copyright":"Copyright &copy mine 2022-2025","modify_label":"文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"java进阶/建造者模式.md","mtime":"2022-06-28T04:14:11.461Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-08-22T03:22:22.085Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sidebar-style/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

